package org.example.servlet;

import com.fasterxml.jackson.databind.ObjectMapper;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/jump2")
public class Jump2Servlet extends HttpServlet {

    private static final ObjectMapper M = new ObjectMapper();

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String username = req.getParameter("username");
        String password = req.getParameter("password");
        //模拟用户登录验证账号密码:
        if("abc".equals(username) && "123".equals(password)){
//            map.put("ok", true);//账号abc，密码123就允许登录
            //登录成功，不返回json数据，直接跳转到response.html
            resp.sendRedirect("views/response.html");
        }else{
            resp.sendRedirect("views/jump.html");
        }

    }
}
